package chen.web.antispam;

import chen.web.MyContext;
import chen.web.MyContextProvider;
import chen.web.user.Account;
import chen.web.user.InternalRoleProvider;

/**
 * 操作者的特征，用于判断是否为同一个操作者
 * @author chen
 *
 */
public abstract class Characteristic {

	private static Characteristic newInstance(Account account){
		return new AccountCharacteristic(account);
	}
	
	private static Characteristic newInstance(String ip, String uuid){
		return new ClientCharacteristic(ip, uuid);
	} 
	
	public static Characteristic newInstance(){
		MyContext context = MyContextProvider.getMyContext();
		Account account = context.getAccount();
		if(account.getRole().equals(InternalRoleProvider.getGuestRole())){
			return newInstance(context.getIp(), context.getUuid());
		}
		return newInstance(account);
	}
}
